    <tr> 
          <td align="center"><strong><font color="#000000">ID</font></strong></td>
          <td nowrap="nowrap"><strong><font color="#000000">Tên Game</font></strong></td>
          <td><strong><font color="#000000">Size</font></strong></td>
          <td><strong><font color="#000000">Giá</font></strong></td>
          <td><strong><font color="#000000">Hình</font></strong></td>
          <td nowrap="nowrap"><strong><font color="#000000">Thể Loại</font></strong></td>
          <td><strong><font color="#000000">Ngày up</font></strong></td>
          <td nowrap="nowrap"><strong><font color="#000000">Loại Game</font></strong></td>
 <td nowrap="nowrap"><strong><font color="#000000">Edit | Delete | Game Hot</font></strong></td>
        </tr>
<?PHP
include("../../DataProvider.php");
if(isset($_GET["page"]))
{
	$page = $_GET["page"];
	$textSrc = "";
	$type = "";
	$sql = "SELECT * FROM tbl_games ";
	if(isset($_GET["textSrc"]) && isset($_GET["type"]))
	{		
		$type = $_GET["type"];
		$textSrc = $_GET["textSrc"];
		$sql = $sql . "where GameName like '%$textSrc%'";
		if($type != 0)
		$sql = $sql." and CategoriesID=$type";
	}
	
		
	$result = DataProvider::ExecuteQuery($sql);
	$tongsorecord = mysql_num_rows($result);
	$y = 9;
	$tongsotrang = ceil($tongsorecord/$y);
if($page > $tongsotrang)
	{
		$page = $tongsotrang;
	}
	$start = ($page-1)*$y;
	
	if(isset($_GET["textSrc"]) && isset($_GET["type"]))
	{
		if($_GET["type"]!= 0)
			$sql = "SELECT * FROM tbl_games where GameName like '%$textSrc%' and CategoriesID=$type Order by CreateDate DESC limit $start,$y ";
		else
			$sql = "SELECT * FROM tbl_games where GameName like '%$textSrc%' Order by CreateDate DESC limit $start,$y ";
	}
	else
	$sql = "SELECT * FROM tbl_games Order by CreateDate DESC limit $start,$y ";
	$result = DataProvider::ExecuteQuery($sql);
	$sql1 = "SELECT * FROM tbl_categories";
	$result1 = DataProvider::ExecuteQuery($sql1);
$new_array =  array();
while ($row1 = mysql_fetch_array($result1)) 
{
    $new_array[$row1['categories']] = $row1['idCategories'];
   
}

while($row = mysql_fetch_array($result))
{
?>
        <tr id="r<?php echo $row['GameID']; ?>"> 
          <td><?php echo $row['GameID']; ?></td>
          <td><a target="new" href="<?php echo $row['GameLink']; ?>"><?php echo $row['GameName']; ?></a></td>
          <td align="right"><?php echo $row['Size']; ?></td>
          <td><?php echo $row['Price']; ?></td>
          <td align="center" style="background:url(<?php echo $row['Artwork']; ?>) no-repeat;background-size:70px; background-position:center" ><img src='../img/mask175_t.png' height="70px" width="70px"/></td>
          <td align="center"><?php
		  $idcate = $row['CategoriesID'];
		  $key = -1;
		  $key = array_search($idcate,$new_array);
		   if($key !=-1)
		   	{
				echo $key;
			}
		   ?></td>
          <td><?php 
		  		$time = strtotime($row["CreateDate"]);
			echo	date("d-m-Y",$time);
		
		  ?></td>
          <td align="center"><?php
		   if($row['Device'] == 1)
		   echo "IPhone";
		   else
		   	if($row['Device'] ==2)
		   		echo "IPad"; 
		   	else
				if($row['Device'] ==3)
					echo "IPhone & IPad";
		   $edit = "'".$row['GameID']."','".$row['GameName']."',".$row['Size'].",". $row['Price'].",".$idcate.",".$row['Device'].",".$row['Status'];
		   ?></td>
         
  <td nowrap="nowrap" align="center"><a href="#<?php echo $row['GameID']; ?>" onclick="editGame(<?php echo $edit; ?>)" ><strong>Edit</strong></a> | <a href="#<?php echo $row['GameID']; ?>" onclick="deleteGame('<?php echo $row['GameID']; ?>')"><strong>Delete</strong></a> | <input type="checkbox" name="myTextEditBox" readonly="readonly" onclick="return false;" <?php if($row['Status'] ==1) echo 'checked="checked"'; ?> 
      style="margin-left:auto; margin-right:auto;" >
</td>
        </tr>
		<?php }?>
        <tr align="right"><td colspan="9"><div class="pagenav"><table cellpadding="3" cellspacing="1" border="0" style="background: none repeat scroll 0 0 #FFFFFF;
    border: 1px solid #B0BDC6;
    color: #000000; margin-right:20px;"><tr><td class="vbmenu_control">Trang <?php echo $page."/".$tongsotrang; ?>&nbsp;</td>
        <?php
        $textSrc ='"'.$textSrc.'"';
        if($page == 1)
			{echo"<td class='alt2'><< Đầu </td>";}
			else
			{
			echo"<td class='alt1'><a style='text-decoration:none;' href='#1' onclick='";
			if(isset($_GET["textSrc"]) && isset($_GET["type"]))
			{
				echo "javascript:searchGameAdmin($textSrc,$type,1)";
			}
			else
			{
				echo "javascript:loadGameAdmin(1)";
			}
			echo "'><< Đầu </a> </td>";
			}
			if($page-3>0)
			$i = $page-3;
			else
			$i = 1;
			for($i;$i<=$tongsotrang;$i++)
			{
				if($tongsotrang < 5)
				{
					if($i == $page)
					{
					 echo "<td class='alt2'>$i</td>";	
					}
					else
					{
						echo "<td class='alt1'><a style='text-decoration:none;' href='#$i' onclick='";
						if(isset($_GET["textSrc"]) && isset($_GET["type"]))
						{
							echo "javascript:searchGameAdmin($textSrc,$type,$i)";
						}
						else
						{
							echo "javascript:loadGameAdmin($i)";
						}
						echo "'> $i</a>  </td>";	
					}
				}
				else
				{
					if($i<$page+4)
					{
						if($i == $page)
						{
						 echo "<td class='alt2'>$i</td>";	
						}
						else
						{
							echo "<td class='alt1'><a style='text-decoration:none;' href='#$i' onclick='";
							if(isset($_GET["textSrc"]) && isset($_GET["type"]))
							{
								echo "javascript:searchGameAdmin($textSrc,$type,$i)";
							}
							else
							{
								echo "javascript:loadGameAdmin($i)";
							}
							echo "'> $i</a>  </td>";	
						}
					}
					else
					{
						echo "<td class='alt1'>...</td>";	
						if( $i * 5 <= $tongsotrang)
						{
							if($i * 5 == $page)
							{
								 echo "<td class='alt2'> $i*5 </td>";
							}
							else
							 echo "<td class='alt1'><a style='text-decoration:none;' href='#$i*5 ' onclick='";
							if(isset($_GET["textSrc"]) && isset($_GET["type"]))
							{
								echo "javascript:searchGameAdmin($textSrc,$type,$i * 5 )";
							}
							else
							{
								echo "javascript:loadGameAdmin($i * 5 )";
							}
							echo "'> $i*5</a>  </td>";
							
							  break;
						}
						else
						{
							if($tongsotrang == $page)
							{
								 echo "<td class='alt2'> $tongsotrang </td>";
							}
							else
							 echo "<td class='alt1'><a style='text-decoration:none;' href='#$tongsotrang' onclick='";
							 if(isset($_GET["textSrc"]) && isset($_GET["type"]))
							{
								echo "javascript:searchGameAdmin($textSrc,$type,$tongsotrang)";
							}
							else
							{
								echo "javascript:loadGameAdmin($tongsotrang)";
							}
							echo "'> $tongsotrang</a>  </td>";
										
								 break;
										
						}
					}
				}
			}
			if($page == $tongsotrang)
				{echo"<td class='alt2'> Cuối >></td>";}
				else
				{
				echo"<td class='alt1' ><a style='text-decoration:none;' href='#$tongsotrang' onclick='";
				if(isset($_GET["textSrc"]) && isset($_GET["type"]))
				{
					echo "javascript:searchGameAdmin($textSrc,$type,$tongsotrang)";
				}
				else
				{
					echo "javascript:loadGameAdmin($tongsotrang)";
				}
				echo "'> Cuối >> </a></td>";
				}
?> <td style="cursor: pointer;" id="pagenav.37" class="vbmenu_control" title="" > <img border="0" alt="" title="" src="../images/menu_open.gif" onclick="showgopage()"><div class="vbmenu_popup" id="pagenav_menu" style="position: absolute; z-index: 999999; clip: rect(auto, auto, auto, auto); display: none;">
		<table cellspacing="1" cellpadding="4" border="0">
		<tbody><tr>
			<td nowrap="nowrap" class="thead" style="background-color:#5C7099;">Go to Page...</td>
		</tr>
		<tr>
			<td class="vbmenu_option" title="">
			<form action='<?php if(isset($_GET["textSrc"]) && isset($_GET["type"]))
				{
					echo "javascript:searchGameAdmin($textSrc,$type,document.gopage.go.value)";
				}
				else
				{
					echo "javascript:loadGameAdmin(document.gopage.go.value)";
				} ?>' method="get" onsubmit="return checkgo();" id="pagenav_form" name="gopage">
				<input type="text" class="bginput" id="pagenav_itxt" name="go" style="font-size:11px" size="4">
				<input type="submit" class="button1" id="pagenav_ibtn" value="Go">
			</form>
			</td>
		</tr>
		</tbody></table>
	</div></td>
</tr></table></td></tr>
<?php
}

?>
